package com.contract.spirit.bean.response

import android.text.TextUtils
import com.contract.spirit.R
import com.contract.spirit.bean.entity.RankInfo
import com.contract.spirit.config.ExchangeType
import com.contract.spirit.manage.CommonConfigManager.configInfoResponse
import java.io.Serializable

/**
 * @author: witness
 * created: 2021/9/17
 * desc:
 */
data class MainPageResponse(
    val inviteAmountPool: String,
    val exchangeList: List<ExchangePollInfo> = listOf(),
    val inviteTopList: List<RankInfo> = listOf(), //邀请奖励排行榜
    val openOrderTopList: List<RankInfo> = listOf(),//开仓达人排行榜
    val gainAmtTopList: List<RankInfo> = listOf()//获赔达人榜表
):Serializable {
    data class ExchangePollInfo(
        val payAmountPool: String,
        val maxPayRate: String,
        val maxPayRateTip: String,
        val exchangeType: String,
        val title: String,
        val status: Int
    ):Serializable{
        fun getMaxPayRateDesc() :String{
            return "$maxPayRate%"
        }
        fun getExchangeLogo(): Int {
            var drawableId = -1
            if (TextUtils.isEmpty(exchangeType)) {
                return drawableId
            }
            when (exchangeType) {
                ExchangeType.BIAN -> drawableId = R.mipmap.icon_bian
                ExchangeType.HUOBI -> drawableId = R.mipmap.icon_huobi
                ExchangeType.OKEX -> drawableId = R.mipmap.icon_okex
            }
            return drawableId
        }
        fun getExhcangeName(): String? {
            var exchangeName = ""
            if (TextUtils.isEmpty(exchangeType)) {
                return ""
            }
            when (exchangeType) {
                ExchangeType.BIAN -> exchangeName = "币安"
                ExchangeType.HUOBI -> exchangeName = "火币"
                ExchangeType.OKEX -> exchangeName = "OKEX"
            }
            return exchangeName
        }

        fun getRegisterExchangeUrl(): String? {

            val regUrlData: VersionInfoResponse.ReqUrlData = configInfoResponse.regUrlData
            var registerUrl  = ""
            if (TextUtils.isEmpty(exchangeType)) {
                return ""
            }
            when (exchangeType) {
                ExchangeType.BIAN -> registerUrl =
                    regUrlData.reg_url_bian
                ExchangeType.HUOBI -> registerUrl =
                    regUrlData.reg_url_huobi
                ExchangeType.OKEX -> registerUrl =
                    regUrlData.reg_url_okex
            }
            return registerUrl
        }


        fun getExchangeInviteCode(): String? {
            val regUrlData: VersionInfoResponse.ReqUrlData =
                configInfoResponse.regUrlData
            var inviteCode = ""
            if (TextUtils.isEmpty(exchangeType)) {
                return ""
            }
            when (exchangeType) {
                ExchangeType.BIAN -> inviteCode =
                    regUrlData.reg_code_bian
                ExchangeType.HUOBI -> inviteCode =
                    regUrlData.reg_cod_huobi
                ExchangeType.OKEX -> inviteCode =
                    regUrlData.reg_code_okex
            }
            return inviteCode
        }

        fun isHasBind(): Boolean {
            return status == 1
        }
    }
}
